//
//  CommunicationManager.h
//  CoolMove
//
//  Created by CA on 14-9-11.
//  Copyright (c) 2014年 CA. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LGBluetooth/LGBluetooth.h"
#import "BTHandler.h"
@import UIKit;

extern NSString * const kCommunicationMangaerModifyNameNotification;

typedef NS_ENUM(NSUInteger, RequestType) {
    RequestTypeScan,        // 扫描
    RequestTypeRealTime     // 实时
};

typedef NS_ENUM(NSUInteger, PatternType) {
    PatternTypetransmission,    // 传输数据
    PatternTypeWaitting         // 等待
};

typedef NS_ENUM(NSUInteger, OperationType) {
    OperationTypePowerOff = 1,      // 关机
    OperationTypeStandby,           // 待机
    OperationTypeReboot,            // 重启
    OperationTypeClean,             // 清空缓存
    OperationTypeReset,             // 还原出厂设置
    
    
    //网球
    OperationTypeChangeDeviceName,  // 设备更名
    OperationTypeBatteryRead,       // 设备电量
    OperationTypeRestartDevice,     // 重启设备
    OperationTypeCloseDevice,       // 关闭设备
    OperationTypeUpdateDevice,      // 固件升级
    OperationTypeCleanData,         // 清除数据
    OperationTypeResetDevice,       // 恢复出厂
    OperationTypeDeviceVersion,     // 固件版本
    OperationTypeHand,                 //设置左右手
    OperationTypeReadRunTimeData,  //读取实时数据
    OperationTypeQuitRunTime,     //退出实时界面
    OperationTypeReadHomePageData, //读取主界面数据
    OperationTypeReadSportDetailData, //动作详情数据读取
    OperationTypeVerify             // 校准
};

typedef void(^OperationBlock)(BOOL success, id feedbackData);

@interface CommunicationManager : NSObject

@property (nonatomic, strong) LGPeripheral *lgPeripheral;
@property (nonatomic, assign, readonly) BOOL isPeripheralConnected;
@property (nonatomic, assign, readonly) BOOL isPeripheralConnectedWithoutAlertView;
@property (nonatomic, assign, readonly) BOOL isCentralReady;
@property (nonatomic, strong) NSNumber *batteryValue;
@property (nonatomic, strong) NSString *modifyName;
@property (nonatomic, assign) BOOL shouldRetryConnect;

+ (instancetype)shareInstance;

- (void)connectPeripheral:(LGPeripheral *)peripheral completion:(CompletionBlock)block;
- (void)setupServicesWithPeripheral:(LGPeripheral *)peripheral completion:(CompletionBlock)block;
- (void)recoverPeripheralWithUUIDString:(NSString *)UUIDString completionBlock:(CompletionBlock)block;
- (void)stopScanningPeripherals;
- (BOOL)isDFUMode;

// 轮滑操作
- (void)performOperationType:(OperationType)operationType object:(id)object completionBlock:(OperationBlock)block;
//一定时间内连接设备，超时连接无重连
- (void)connectWithoutRetryConnectPeripheralUUID:(NSString *)uuidStr completion:(CompletionBlock)block;
- (void)disconnectThePeripheralWithCompletionBlock:(CompletionBlock)block;


@end
